<h2>Корзина</h2>

<table width="100%">
<tr>
    <th>Наименование</th>
    <th>Количество</th>
    <th>Цена</th>
    <th>Сумма</th>
</tr>
<?php    
    $cart = unserialize($this->session->userdata('usercart'));
    if($cart != FALSE) {
        $this->db->where_in('id', array_keys($cart));
        $query = $this->db->get('stuff');
        if($query->num_rows() > 0) {
            $stuff = $query->result_array();
            foreach($stuff as $index => $st) {
                $goods[$st['id']] = $stuff[$index];              
            }                        
            foreach($cart as $item) {
                $amount = $item['amount'];
                $price = $goods[$item['id']]['price'];
                $sum = $amount * $price;
                print '
                    <tr>
                    <td>'.$goods[$item['id']]['title'].'</td>
                    <td>'.$amount.'</td>
                    <td>'.$price.' руб</td>
                    <td>'.$sum.' руб</td>
                    </tr>
                ';
            }
        }
    }
?>
</table>
<br />
<?php print anchor('cart/flush', 'Очистить корзину'); ?> | 
<?php print anchor('cart/confirm', 'Оформить заказ'); ?>
